set(LLVM_CodeGen_DIR ${LLVM_MAIN_SRC_DIR}/lib/CodeGen)

add_llvm_component_library(LLVMBuddyCodeGen
  ${LLVM_CodeGen_DIR}/AggressiveAntiDepBreaker.cpp
  ${LLVM_CodeGen_DIR}/AllocationOrder.cpp
  ${LLVM_CodeGen_DIR}/Analysis.cpp
  ${LLVM_CodeGen_DIR}/AssignmentTrackingAnalysis.cpp
  ${LLVM_CodeGen_DIR}/AtomicExpandPass.cpp
  ${LLVM_CodeGen_DIR}/BasicTargetTransformInfo.cpp
  ${LLVM_CodeGen_DIR}/BranchFolding.cpp
  ${LLVM_CodeGen_DIR}/BranchRelaxation.cpp
  ${LLVM_CodeGen_DIR}/BreakFalseDeps.cpp
  ${LLVM_CodeGen_DIR}/BasicBlockSections.cpp
  ${LLVM_CodeGen_DIR}/BasicBlockPathCloning.cpp
  ${LLVM_CodeGen_DIR}/BasicBlockSectionsProfileReader.cpp
  ${LLVM_CodeGen_DIR}/CalcSpillWeights.cpp
  ${LLVM_CodeGen_DIR}/CallBrPrepare.cpp
  ${LLVM_CodeGen_DIR}/CallingConvLower.cpp
  ${LLVM_CodeGen_DIR}/CFGuardLongjmp.cpp
  ${LLVM_CodeGen_DIR}/CFIFixup.cpp
  ${LLVM_CodeGen_DIR}/CFIInstrInserter.cpp
  ${LLVM_CodeGen_DIR}/CodeGen.cpp
  ${LLVM_CodeGen_DIR}/CodeGenCommonISel.cpp
  ${LLVM_CodeGen_DIR}/CodeGenPrepare.cpp
  ${LLVM_CodeGen_DIR}/CommandFlags.cpp
  ${LLVM_CodeGen_DIR}/ComplexDeinterleavingPass.cpp
  ${LLVM_CodeGen_DIR}/CriticalAntiDepBreaker.cpp
  ${LLVM_CodeGen_DIR}/DeadMachineInstructionElim.cpp
  ${LLVM_CodeGen_DIR}/DetectDeadLanes.cpp
  ${LLVM_CodeGen_DIR}/DFAPacketizer.cpp
  ${LLVM_CodeGen_DIR}/DwarfEHPrepare.cpp
  ${LLVM_CodeGen_DIR}/EarlyIfConversion.cpp
  ${LLVM_CodeGen_DIR}/EdgeBundles.cpp
  ${LLVM_CodeGen_DIR}/EHContGuardCatchret.cpp
  ${LLVM_CodeGen_DIR}/ExecutionDomainFix.cpp
  ${LLVM_CodeGen_DIR}/ExpandLargeDivRem.cpp
  ${LLVM_CodeGen_DIR}/ExpandLargeFpConvert.cpp
  ${LLVM_CodeGen_DIR}/ExpandMemCmp.cpp
  ${LLVM_CodeGen_DIR}/ExpandPostRAPseudos.cpp
  ${LLVM_CodeGen_DIR}/ExpandReductions.cpp
  ${LLVM_CodeGen_DIR}/ExpandVectorPredication.cpp
  ${LLVM_CodeGen_DIR}/FaultMaps.cpp
  ${LLVM_CodeGen_DIR}/FEntryInserter.cpp
  ${LLVM_CodeGen_DIR}/FinalizeISel.cpp
  ${LLVM_CodeGen_DIR}/FixupStatepointCallerSaved.cpp
  ${LLVM_CodeGen_DIR}/FuncletLayout.cpp
  ${LLVM_CodeGen_DIR}/MachineFunctionAnalysis.cpp
  ${LLVM_CodeGen_DIR}/GCMetadata.cpp
  ${LLVM_CodeGen_DIR}/GCMetadataPrinter.cpp
  ${LLVM_CodeGen_DIR}/GCRootLowering.cpp
  ${LLVM_CodeGen_DIR}/GlobalMerge.cpp
  ${LLVM_CodeGen_DIR}/GlobalMergeFunctions.cpp
  ${LLVM_CodeGen_DIR}/HardwareLoops.cpp
  ${LLVM_CodeGen_DIR}/IfConversion.cpp
  ${LLVM_CodeGen_DIR}/ImplicitNullChecks.cpp
  ${LLVM_CodeGen_DIR}/IndirectBrExpandPass.cpp
  ${LLVM_CodeGen_DIR}/InitUndef.cpp
  ${LLVM_CodeGen_DIR}/InlineSpiller.cpp
  ${LLVM_CodeGen_DIR}/InterferenceCache.cpp
  ${LLVM_CodeGen_DIR}/InterleavedAccessPass.cpp
  ${LLVM_CodeGen_DIR}/InterleavedLoadCombinePass.cpp
  ${LLVM_CodeGen_DIR}/IntrinsicLowering.cpp
  ${LLVM_CodeGen_DIR}/JMCInstrumenter.cpp
  ${LLVM_CodeGen_DIR}/KCFI.cpp
  ${LLVM_CodeGen_DIR}/LatencyPriorityQueue.cpp
  ${LLVM_CodeGen_DIR}/LazyMachineBlockFrequencyInfo.cpp
  ${LLVM_CodeGen_DIR}/LexicalScopes.cpp
  ${LLVM_CodeGen_DIR}/LiveDebugVariables.cpp
  ${LLVM_CodeGen_DIR}/LiveIntervals.cpp
  ${LLVM_CodeGen_DIR}/LiveInterval.cpp
  ${LLVM_CodeGen_DIR}/LiveIntervalUnion.cpp
  ${LLVM_CodeGen_DIR}/LivePhysRegs.cpp
  ${LLVM_CodeGen_DIR}/LiveRangeCalc.cpp
  ${LLVM_CodeGen_DIR}/LiveIntervalCalc.cpp
  ${LLVM_CodeGen_DIR}/LiveRangeEdit.cpp
  ${LLVM_CodeGen_DIR}/LiveRangeShrink.cpp
  ${LLVM_CodeGen_DIR}/LiveRegMatrix.cpp
  ${LLVM_CodeGen_DIR}/LiveRegUnits.cpp
  ${LLVM_CodeGen_DIR}/LiveStacks.cpp
  ${LLVM_CodeGen_DIR}/LiveVariables.cpp
  ${LLVM_CodeGen_DIR}/CodeGenTargetMachineImpl.cpp
  ${LLVM_CodeGen_DIR}/LocalStackSlotAllocation.cpp
  ${LLVM_CodeGen_DIR}/LoopTraversal.cpp
  ${LLVM_CodeGen_DIR}/LowLevelTypeUtils.cpp
  ${LLVM_CodeGen_DIR}/LowerEmuTLS.cpp
  ${LLVM_CodeGen_DIR}/MachineBasicBlock.cpp
  ${LLVM_CodeGen_DIR}/MachineBlockFrequencyInfo.cpp
  ${LLVM_CodeGen_DIR}/MachineBlockPlacement.cpp
  ${LLVM_CodeGen_DIR}/MachineBranchProbabilityInfo.cpp
  ${LLVM_CodeGen_DIR}/MachineCFGPrinter.cpp
  ${LLVM_CodeGen_DIR}/MachineCombiner.cpp
  ${LLVM_CodeGen_DIR}/MachineConvergenceVerifier.cpp
  ${LLVM_CodeGen_DIR}/MachineCopyPropagation.cpp
  ${LLVM_CodeGen_DIR}/MachineCSE.cpp
  ${LLVM_CodeGen_DIR}/MachineCheckDebugify.cpp
  ${LLVM_CodeGen_DIR}/MachineCycleAnalysis.cpp
  ${LLVM_CodeGen_DIR}/MachineDebugify.cpp
  ${LLVM_CodeGen_DIR}/MachineDomTreeUpdater.cpp
  ${LLVM_CodeGen_DIR}/MachineDominanceFrontier.cpp
  ${LLVM_CodeGen_DIR}/MachineDominators.cpp
  ${LLVM_CodeGen_DIR}/MachineFrameInfo.cpp
  ${LLVM_CodeGen_DIR}/MachineFunction.cpp
  ${LLVM_CodeGen_DIR}/MachineFunctionPass.cpp
  ${LLVM_CodeGen_DIR}/MachineFunctionPrinterPass.cpp
  ${LLVM_CodeGen_DIR}/MachineFunctionSplitter.cpp
  ${LLVM_CodeGen_DIR}/MachineInstrBundle.cpp
  ${LLVM_CodeGen_DIR}/MachineInstr.cpp
  ${LLVM_CodeGen_DIR}/MachineLateInstrsCleanup.cpp
  ${LLVM_CodeGen_DIR}/MachineLICM.cpp
  ${LLVM_CodeGen_DIR}/MachineLoopInfo.cpp
  ${LLVM_CodeGen_DIR}/MachineLoopUtils.cpp
  ${LLVM_CodeGen_DIR}/MachineModuleInfo.cpp
  ${LLVM_CodeGen_DIR}/MachineModuleInfoImpls.cpp
  ${LLVM_CodeGen_DIR}/MachineModuleSlotTracker.cpp
  ${LLVM_CodeGen_DIR}/MachineOperand.cpp
  ${LLVM_CodeGen_DIR}/MachineOptimizationRemarkEmitter.cpp
  ${LLVM_CodeGen_DIR}/MachineOutliner.cpp
  ${LLVM_CodeGen_DIR}/MachinePassManager.cpp
  ${LLVM_CodeGen_DIR}/MachinePipeliner.cpp
  ${LLVM_CodeGen_DIR}/MachinePostDominators.cpp
  ${LLVM_CodeGen_DIR}/MachineRegionInfo.cpp
  ${LLVM_CodeGen_DIR}/MachineRegisterInfo.cpp
  ${LLVM_CodeGen_DIR}/MachineScheduler.cpp
  ${LLVM_CodeGen_DIR}/MachineSink.cpp
  ${LLVM_CodeGen_DIR}/MachineSizeOpts.cpp
  ${LLVM_CodeGen_DIR}/MachineSSAContext.cpp
  ${LLVM_CodeGen_DIR}/MachineSSAUpdater.cpp
  ${LLVM_CodeGen_DIR}/MachineStripDebug.cpp
  ${LLVM_CodeGen_DIR}/MachineTraceMetrics.cpp
  ${LLVM_CodeGen_DIR}/MachineUniformityAnalysis.cpp
  ${LLVM_CodeGen_DIR}/MachineVerifier.cpp
  ${LLVM_CodeGen_DIR}/MIRFSDiscriminator.cpp
  ${LLVM_CodeGen_DIR}/MIRSampleProfile.cpp
  ${LLVM_CodeGen_DIR}/MIRYamlMapping.cpp
  ${LLVM_CodeGen_DIR}/MLRegAllocEvictAdvisor.cpp
  ${LLVM_CodeGen_DIR}/MLRegAllocPriorityAdvisor.cpp
  ${LLVM_CodeGen_DIR}/ModuloSchedule.cpp
  ${LLVM_CodeGen_DIR}/MultiHazardRecognizer.cpp
  ${LLVM_CodeGen_DIR}/PatchableFunction.cpp
  ${LLVM_CodeGen_DIR}/MBFIWrapper.cpp
  ${LLVM_CodeGen_DIR}/MIRPrinter.cpp
  ${LLVM_CodeGen_DIR}/MIRPrintingPass.cpp
  ${LLVM_CodeGen_DIR}/MacroFusion.cpp
  ${LLVM_CodeGen_DIR}/NonRelocatableStringpool.cpp
  ${LLVM_CodeGen_DIR}/OptimizePHIs.cpp
  ${LLVM_CodeGen_DIR}/PeepholeOptimizer.cpp
  ${LLVM_CodeGen_DIR}/PHIElimination.cpp
  ${LLVM_CodeGen_DIR}/PHIEliminationUtils.cpp
  ${LLVM_CodeGen_DIR}/PostRAHazardRecognizer.cpp
  ${LLVM_CodeGen_DIR}/PostRASchedulerList.cpp
  ${LLVM_CodeGen_DIR}/PreISelIntrinsicLowering.cpp
  ${LLVM_CodeGen_DIR}/ProcessImplicitDefs.cpp
  ${LLVM_CodeGen_DIR}/PrologEpilogInserter.cpp
  ${LLVM_CodeGen_DIR}/PseudoProbeInserter.cpp
  ${LLVM_CodeGen_DIR}/PseudoSourceValue.cpp
  ${LLVM_CodeGen_DIR}/RDFGraph.cpp
  ${LLVM_CodeGen_DIR}/RDFLiveness.cpp
  ${LLVM_CodeGen_DIR}/RDFRegisters.cpp
  ${LLVM_CodeGen_DIR}/ReachingDefAnalysis.cpp
  ${LLVM_CodeGen_DIR}/RegAllocBase.cpp
  ${LLVM_CodeGen_DIR}/RegAllocBasic.cpp
  ${LLVM_CodeGen_DIR}/RegAllocEvictionAdvisor.cpp
  ${LLVM_CodeGen_DIR}/RegAllocFast.cpp
  ${LLVM_CodeGen_DIR}/RegAllocGreedy.cpp
  ${LLVM_CodeGen_DIR}/RegAllocPBQP.cpp
  ${LLVM_CodeGen_DIR}/RegAllocPriorityAdvisor.cpp
  ${LLVM_CodeGen_DIR}/RegAllocScore.cpp
  ${LLVM_CodeGen_DIR}/RegisterClassInfo.cpp
  ${LLVM_CodeGen_DIR}/RegisterCoalescer.cpp
  ${LLVM_CodeGen_DIR}/RegisterPressure.cpp
  ${LLVM_CodeGen_DIR}/RegisterScavenging.cpp
  ${LLVM_CodeGen_DIR}/GCEmptyBasicBlocks.cpp
  ${LLVM_CodeGen_DIR}/RemoveRedundantDebugValues.cpp
  ${LLVM_CodeGen_DIR}/RenameIndependentSubregs.cpp
  ${LLVM_CodeGen_DIR}/MachineStableHash.cpp
  ${LLVM_CodeGen_DIR}/MIRVRegNamerUtils.cpp
  ${LLVM_CodeGen_DIR}/MIRNamerPass.cpp
  ${LLVM_CodeGen_DIR}/MIRCanonicalizerPass.cpp
  ${LLVM_CodeGen_DIR}/RegisterUsageInfo.cpp
  ${LLVM_CodeGen_DIR}/RegUsageInfoCollector.cpp
  ${LLVM_CodeGen_DIR}/RegUsageInfoPropagate.cpp
  ${LLVM_CodeGen_DIR}/RemoveLoadsIntoFakeUses.cpp
  ${LLVM_CodeGen_DIR}/ReplaceWithVeclib.cpp
  ${LLVM_CodeGen_DIR}/ResetMachineFunctionPass.cpp
  ${LLVM_CodeGen_DIR}/RegisterBank.cpp
  ${LLVM_CodeGen_DIR}/RegisterBankInfo.cpp
  ${LLVM_CodeGen_DIR}/SafeStack.cpp
  ${LLVM_CodeGen_DIR}/SafeStackLayout.cpp
  ${LLVM_CodeGen_DIR}/SanitizerBinaryMetadata.cpp
  ${LLVM_CodeGen_DIR}/ScheduleDAG.cpp
  ${LLVM_CodeGen_DIR}/ScheduleDAGInstrs.cpp
  ${LLVM_CodeGen_DIR}/ScheduleDAGPrinter.cpp
  ${LLVM_CodeGen_DIR}/ScoreboardHazardRecognizer.cpp
  ${LLVM_CodeGen_DIR}/SelectOptimize.cpp
  ${LLVM_CodeGen_DIR}/ShadowStackGCLowering.cpp
  ${LLVM_CodeGen_DIR}/ShrinkWrap.cpp
  ${LLVM_CodeGen_DIR}/SjLjEHPrepare.cpp
  ${LLVM_CodeGen_DIR}/SlotIndexes.cpp
  ${LLVM_CodeGen_DIR}/SpillPlacement.cpp
  ${LLVM_CodeGen_DIR}/SplitKit.cpp
  ${LLVM_CodeGen_DIR}/StackColoring.cpp
  ${LLVM_CodeGen_DIR}/StackFrameLayoutAnalysisPass.cpp
  ${LLVM_CodeGen_DIR}/StackMapLivenessAnalysis.cpp
  ${LLVM_CodeGen_DIR}/StackMaps.cpp
  ${LLVM_CodeGen_DIR}/StackProtector.cpp
  ${LLVM_CodeGen_DIR}/StackSlotColoring.cpp
  ${LLVM_CodeGen_DIR}/StaticDataSplitter.cpp
  ${LLVM_CodeGen_DIR}/SwiftErrorValueTracking.cpp
  ${LLVM_CodeGen_DIR}/SwitchLoweringUtils.cpp
  ${LLVM_CodeGen_DIR}/TailDuplication.cpp
  ${LLVM_CodeGen_DIR}/TailDuplicator.cpp
  ${LLVM_CodeGen_DIR}/TargetFrameLoweringImpl.cpp
  ${LLVM_CodeGen_DIR}/TargetInstrInfo.cpp
  ${LLVM_CodeGen_DIR}/TargetLoweringBase.cpp
  ${LLVM_CodeGen_DIR}/TargetLoweringObjectFileImpl.cpp
  ${LLVM_CodeGen_DIR}/TargetOptionsImpl.cpp
  ${LLVM_CodeGen_DIR}/TargetPassConfig.cpp
  ${LLVM_CodeGen_DIR}/TargetRegisterInfo.cpp
  ${LLVM_CodeGen_DIR}/TargetSchedule.cpp
  ${LLVM_CodeGen_DIR}/TargetSubtargetInfo.cpp
  ${LLVM_CodeGen_DIR}/TwoAddressInstructionPass.cpp
  ${LLVM_CodeGen_DIR}/TypePromotion.cpp
  ${LLVM_CodeGen_DIR}/UnreachableBlockElim.cpp
  ${LLVM_CodeGen_DIR}/ValueTypes.cpp
  ${LLVM_CodeGen_DIR}/VLIWMachineScheduler.cpp
  ${LLVM_CodeGen_DIR}/VirtRegMap.cpp
  ${LLVM_CodeGen_DIR}/WasmEHPrepare.cpp
  ${LLVM_CodeGen_DIR}/WindowScheduler.cpp
  ${LLVM_CodeGen_DIR}/WinEHPrepare.cpp
  ${LLVM_CodeGen_DIR}/XRayInstrumentation.cpp



  ${GeneratedMLSources}

  ${LLVM_CodeGen_DIR}/LiveDebugValues/LiveDebugValues.cpp
  ${LLVM_CodeGen_DIR}/LiveDebugValues/VarLocBasedImpl.cpp
  ${LLVM_CodeGen_DIR}/LiveDebugValues/InstrRefBasedImpl.cpp

  ADDITIONAL_HEADER_DIRS
  ${LLVM_MAIN_INCLUDE_DIR}/llvm/CodeGen
  ${LLVM_MAIN_INCLUDE_DIR}/llvm/CodeGen/PBQP

  LINK_LIBS ${LLVM_PTHREAD_LIB} ${MLLinkDeps}

  DEPENDS
  buddy_intrinsics_gen
  ${MLDeps}

  LINK_COMPONENTS
  BuddyAnalysis
  BuddyBitReader
  BuddyBitWriter
  BuddyCore
  MC
  ObjCARC
  BuddyProfileData
  BuddyScalar
  Support
  BuddyTarget
  BuddyTransformUtils

  )

add_subdirectory(SelectionDAG)
add_subdirectory(AsmPrinter)
add_subdirectory(MIRParser)
